package com.easidea.tim.entity.purchase;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.supply.Sup;

/**
 * 采购合同Model
 * @author Administrator
 *
 */
@Entity(name="tim_purchase_order")
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Undeletable(status="deleted")
@Cache(region="tim_purchase_order",usage=CacheConcurrencyStrategy.READ_WRITE)
public class PurchaseOrder extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//流水号
	private String flowNo;
	//合同号
	private String purchaseOrderNum;
	//备注
	private String memo;
	//是否星标
	private boolean starFlag;
	//
	private Double totalAmount;
	//总米数
	private Double totalMeter;
	//是否完成的标志
	private boolean status;
	//关闭日期
	private Date closeDate;
	//关闭人
	private String closeMan;
	//要求全部到货最后日期
	private Date requireDate;
	//供应商
	private Sup supplier;
	
	private List<PurchaseOrderItem> items;
	
	@Column(name="flowNo")
	public String getFlowNo() {
		return flowNo;
	}
	public void setFlowNo(String flowNo) {
		this.flowNo = flowNo;
	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="purchaseOrder")	
	@Where(clause="deleted <> 1")
	public List<PurchaseOrderItem> getItems() {
		return items;
	}
	public void setItems(List<PurchaseOrderItem> items) {
		this.items = items;
	}
	@Column(name="purchase_order_num", nullable=false)
	public String getPurchaseOrderNum() {
		return purchaseOrderNum;
	}
	public void setPurchaseOrderNum(String purchaseOrderNum) {
		this.purchaseOrderNum = purchaseOrderNum;
	}
	@Column(name="memo")
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	@Column(name="is_star_flag", nullable=false)
	public boolean isStarFlag() {
		return starFlag;
	}
	public void setStarFlag(boolean starFlag) {
		this.starFlag = starFlag;
	}
	@Column(name="total_amount", nullable=false)
	public Double getTotalAmount() {
		return totalAmount;
	}
	
	public void setTotalAmount(Double totalAmount) {
		this.totalAmount = totalAmount;
	}
	@Column(name="total_meter", nullable=false)
	public Double getTotalMeter() {
		return totalMeter;
	}
	public void setTotalMeter(Double totalMeter) {
		this.totalMeter = totalMeter;
	}
	@Column(name="is_status", nullable=false)
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	@Column(name="close_date", nullable=true)
	public Date getCloseDate() {
		return closeDate;
	}

	public void setCloseDate(Date closeDate) {
		this.closeDate = closeDate;
	}
	@Column(name="close_man", nullable=true)
	public String getCloseMan() {
		return closeMan;
	}
	public void setCloseMan(String closeMan) {
		this.closeMan = closeMan;
	}
	@Column(name="require_date")
	public Date getRequireDate() {
		return requireDate;
	}
	public void setRequireDate(Date requireDate) {
		this.requireDate = requireDate;
	}
	@ManyToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="supplier_id")
	public Sup getSupplier() {
		return supplier;
	}
	public void setSupplier(Sup supplier) {
		this.supplier = supplier;
	}

	
}
